﻿using System;
using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTTypeDeclEnum : ASTNamespaceTypeDecl
    {
        public ASTTypeName baseType { get; set; }
        public readonly ASTEnumMemberDecls members = new ASTEnumMemberDecls();

        public override string ToString()
        {
            depth++;

            string mods = "";

            if (Mods.has(modifiers, Mods.unsafeMod      )) mods += "unsafe ";
            if (Mods.has(modifiers, Mods.publicMod      )) mods += "public ";
            if (Mods.has(modifiers, Mods.privateMod     )) mods += "private ";
            if (Mods.has(modifiers, Mods.internalMod    )) mods += "internal ";
            if (Mods.has(modifiers, Mods.protectedMod   )) mods += "protected ";

            string ret = mods + string.Format("enum {0}", name);

            if (baseType != null)
                ret += string.Format(" : {0}", baseType);

            ret = Strings.tab(depth) + ret;
            ret += Environment.NewLine + Strings.tab(depth) + "{";
            ret += Environment.NewLine;
            ret += members.ToString();
            ret += members.hasFinalComma ? "," : "";
            ret += Environment.NewLine + Strings.tab(depth) + "}";
            if (hasFinalComma) ret += ";";

            depth--;

            return ret;
        }
    }
}
